//供其他页面调用声明
function __g_reloadData(){
	$(".datagrid:visible .tablex").datagrid("reload");
}

function edit(node,event){
	var url = $(node).data("url");
	top.__t_tabAdd("修改角色",url,window.name);
	event.stopPropagation();
};


function before(){

}

function init(){
	$('#table0').datagrid({
		"url" : "sys/role/query",
		"toolbar": [{
			iconCls: 'fa fa-plus',
			text:"增加",
			handler: function(){
				top.__t_tabAdd("新增","sys/role/add",window.name);
			}
		},'-',{
			iconCls: 'fa fa-recycle',
			text:"删除",
			handler: function(){
				var ids = $('#table0').datagrid("getCheckedIds");
				if($.isEmptyObject(ids)){
					$.messagebox.alert("请选择需要删除的记录","warning");
					return;
				}
				$.messagebox.confirm("是否删除记录",function(yes){
					if(yes){
						$.post("sys/role/delete",$.param({"ids":ids},true),function(res){
							if(res.success){
								$.messagebox.toast("删除成功","success");
								$('#table0').datagrid("reload");
							}else{
								$.messagebox.toast("删除失败:"+res.returnMessage,"danger");
							}
						},"json");
					}
				});

			}
		},"-"],
		"columns" : [ [ {
			field : 'ck',
			checkbox : true
		},{
			field : 'name',
			title : '<center><b>角色名</b></center>',
			width : 100,
			align : 'left',
			formatter : function(val,row,index){
				var domTmp = "<a class='edit' href='javascript:void(0);' onclick='edit(this,arguments[0])' data-url='sys/role/edit?id={0}' >{1}</a>";
				return $.validator.format(domTmp,row.id,row.name);
			}
		}] ],

	}).datagrid('getPager').pagination();
	
	
/*
	$('#tableRecycle').datagrid({
		"url" : "sys/role/queryRecycle",
		"toolbar": [{
			iconCls: 'fa fa-times',
			text:"清空",
			handler: function(){
				var ids = $('#tableRecycle').datagrid("getCheckedIds");
				if($.isEmptyObject(ids)){
					$.messagebox.alert("请选择需要清空的记录");
					return;
				}
				$.post("sys/role/delete",$.param({"ids":ids},true),function(res){
					if(res.success){
						$.messagebox.toast("清空成功","success");
						$('#tableRecycle').datagrid("reload");
					}else{
						$.messagebox.toast("清空失败:"+res.message,"danger");
					}
				});
			}
		}],
		"columns" : [ [ {
			field : 'ck',
			checkbox : true
		}, {
			field : 'name',
			title : '<center><b>角色名</b></center>',
			width : 100,
			align : 'left',
			formatter : function(val,row,index){
				var domTmp = "<a class='edit' href='javascript:void(0);' data-url='sys/role/edit?id={0}' >{1}</a>";
				return $.validator.format(domTmp,row.id,row.name);
			}
		} ] ],

	}).datagrid('getPager').pagination();
	*/

	
	__p_resizeable($(".tablex"));

    
};


function after(){
	
}